﻿namespace 数字化加工图像
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;

    public class Form2 : Form
    {
        private Button button1;
        private Button button2;
        private IContainer components;
        private List<string> liststring = new List<string>();
        private SaveFileDialog saveFileDialog1;
        private TextBox textBox1;

        public Form2(List<string> list)
        {
            this.InitializeComponent();
            this.liststring = list;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using (FileStream stream = new FileStream(this.saveFileDialog1.FileName, FileMode.Create))
                {
                    stream.Dispose();
                }
                foreach (string str in this.liststring)
                {
                    using (FileStream stream2 = new FileStream(this.saveFileDialog1.FileName, FileMode.Append))
                    {
                        byte[] bytes = Encoding.Default.GetBytes(str);
                        stream2.Write(bytes, 0, bytes.Length);
                        stream2.Dispose();
                    }
                }
                base.Dispose();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            base.Dispose();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            try
            {
                foreach (string str in this.liststring)
                {
                    this.textBox1.AppendText(str);
                }
            }
            catch
            {
                MessageBox.Show("异常条目过多，无法完全显示!");
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Form2));
            this.textBox1 = new TextBox();
            this.button1 = new Button();
            this.button2 = new Button();
            this.saveFileDialog1 = new SaveFileDialog();
            base.SuspendLayout();
            this.textBox1.Location = new Point(1, 1);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ScrollBars = ScrollBars.Both;
            this.textBox1.Size = new Size(0x28f, 0x1bb);
            this.textBox1.TabIndex = 0;
            this.button1.Location = new Point(0x11b, 0x1c0);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0x5b, 0x17);
            this.button1.TabIndex = 1;
            this.button1.Text = "保存并关闭";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            this.button2.Location = new Point(0x245, 0x1c0);
            this.button2.Name = "button2";
            this.button2.Size = new Size(0x4b, 0x17);
            this.button2.TabIndex = 2;
            this.button2.Text = "关闭";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new EventHandler(this.button2_Click);
            this.saveFileDialog1.DefaultExt = "txt";
            this.saveFileDialog1.FileName = "异常报告";
            this.saveFileDialog1.Filter = "*.txt|";
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x291, 0x1da);
            base.Controls.Add(this.button2);
            base.Controls.Add(this.button1);
            base.Controls.Add(this.textBox1);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "Form2";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "异常报告";
            base.Load += new EventHandler(this.Form2_Load);
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

